package com.hyjoy.web.servlet;

import com.hyjoy.service.CategoryService;
import com.hyjoy.service.impl.CategoryServiceImpl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by hyjoy on 2018/4/5.
 */
public class CategoryServlet extends BaseServlet {


    public String findAll(HttpServletRequest request, HttpServletResponse response) throws Exception {
        // 设置响应编码
        response.setContentType("text/html;charset=utf-8");
        // 调用service，查询所有分类，返回值json字符串
        CategoryService categoryService = new CategoryServiceImpl();
        // 从mysql获取列表
        String value = null;
        try {
            value = categoryService.findAll();
            // 降字符串写回浏览器
            response.getWriter().println(value);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }


}
